1913A - Rating Increase - CodeForces Solution


implementation

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fr(i, n) for (ll i = 0; i < n; i++)
#define PB push_back
#define MP make_pair
#define F first
#define S second
ll const N = 1e5;

bool isPrime(ll n)
{

    if (n <= 1)
        return false;

    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;

    return true;
}
ll fact(ll n)
{
    if (n == 0)
        return 1;
    return n * fact(n - 1);
}
int divCount(int n)
{
    // sieve method for prime calculation
    bool hash[n + 1];
    memset(hash, true, sizeof(hash));
    for (int p = 2; p * p < n; p++)
        if (hash[p] == true)
            for (int i = p * 2; i < n; i += p)
                hash[i] = false;

    // Traversing through all prime numbers
    int total = 1;
    for (int p = 2; p <= n; p++)
    {
        if (hash[p])
        {

            int count = 0;
            if (n % p == 0)
            {
                while (n % p == 0)
                {
                    n = n / p;
                    count++;
                }
                total = total * (count + 1);
            }
        }
    }
    return total;
}

vector<ll> prfact(ll n, vector<ll> v)
{

    for (ll i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
            v.push_back(i);
        v.push_back(n / i);
    }
    return v;
}

ll countSetBits(ll n)
{
    ll count = 0;
    while (n)
    {
        count += n & 1;
        n >>= 1;
    }
    return count;
}

ll setBit(ll n, ll k)
{
    return ((1 << k) | n);
}

ll power(ll x, ll y, ll p)
{

    ll res = 1;
    while (y > 0)
    {
        if (y % 2 == 1)
            res = (res * x);
        y = y >> 1;
        x = (x * x);
    }
    return res % p;
}
int msbPos(ll n)
{
    int msb_p = -1;
    while (n)
    {
        n = n >> 1;
        msb_p++;
    }
    return msb_p;
}

ll andinrange(ll a, ll b)
{

    int shiftcount = 0;
    while (a != b and a > 0)
    {
        shiftcount++;
        a = a >> 1;
        b = b >> 1;
    }
    return (a << shiftcount);
}
ll sumDigits(ll no)
{
    if (no == 0)
    {
        return 0;
    }

    return (no % 10) + sumDigits(no / 10);
}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

// Function to find gcd of array of
// numbers
int findGCD(int arr[], int n)
{
    int result = arr[0];
    for (int i = 1; i < n; i++)
    {
        result = gcd(arr[i], result);

        if (result == 1)
        {
            return 1;
        }
    }
    return result;
}
bool isSubstring(string s1, string s2)
{
    int M = s1.length();
    int N = s2.length();

    /* A loop to slide pat[] one by one */
    for (int i = 0; i <= N - M; i++)
    {
        int j;

        /* For current index i, check for
 pattern match */
        for (j = 0; j < M; j++)
            if (s2[i + j] != s1[j])
                break;

        if (j == M)
            return 1;
    }

    return 0;
}
bool isPalindrome(string S)
{
    // Stores the reverse of the
    // string S
    string P = S;

    // Reverse the string P
    reverse(P.begin(), P.end());

    // If S is equal to P
    if (S == P)
    {
        // Return "Yes"
        return 1;
    }
    // Otherwise
    else
    {
        // return "No"
        return 0;
    }
}
ll fnc(ll x, ll y, ll d)
{
    ll count = (y - x) / d;
    if ((y - x) % d == 0)
    {
        count--;
    }
    return count + 1;
}
string revs(string s)
{
    string ss;
    for (ll i = 0; i < s.size(); i++)
    {
        ss.push_back(s[s.size() - 1 - i]);
    }
    return ss;
}
ll orr(ll n, ll m)
{
    ll rr = 1 << (m - 1);
    return rr | n;
}

// Code for problem goes here.................................................................................
ll mod = 998244353;
void solve()
{
    string s;
    cin>>s;
    ll n=s.length();
    string form1="",form2="";
    for(ll i=0;i<n/2;i++)
    {
        form1+=s[i];
        form2="";
        for(ll j=i+1;j<n;j++)
        {
            if(form2.length()==0 && s[j]=='0')
            break;
            form2+=s[j];
        }
        if(form2.length()==0)
        continue;
        ll use1=stoi(form1);
        ll use2=stoi(form2);
        if(use2>use1)
        {
            cout<<use1<<" "<<use2<<endl;
            return;
        }
    }
    cout<<-1<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin >> t;
    while (t--)

    solve();

    return 0;
}


Comments

Submit
0 Comments
More Questions

1535A - Fair Playoff
1538F - Interesting Function
1920. Build Array from Permutation
494. Target Sum
797. All Paths From Source to Target
1547B - Alphabetical Strings
1550A - Find The Array
118B - Present from Lena
27A - Next Test
785. Is Graph Bipartite
90. Subsets II
1560A - Dislike of Threes
36. Valid Sudoku
557. Reverse Words in a String III
566. Reshape the Matrix
167. Two Sum II - Input array is sorted
387. First Unique Character in a String
383. Ransom Note
242. Valid Anagram
141. Linked List Cycle
21. Merge Two Sorted Lists
203. Remove Linked List Elements
733. Flood Fill
206. Reverse Linked List
83. Remove Duplicates from Sorted List
116. Populating Next Right Pointers in Each Node
145. Binary Tree Postorder Traversal
94. Binary Tree Inorder Traversal
101. Symmetric Tree
77. Combinations